<template>

</template>

<script lang="ts">
import {defineComponent, Ref, ref} from 'vue'

export default defineComponent({
  name: "BattleView",
  setup(){
    const ws:Ref<WebSocket|null>=ref(null);
    const onWsOpen=()=>{
      console.log('ws open')
    }
    const onWsClose=()=>{
      console.log('ws close')
    }
    const onWsError=()=>{
      console.log('ws error')
    }
    const onWsMessage=()=>{
      console.log('ws message')
    }
    const onESCreate=(params)=>{
      try {
        let url='ws://10.0.2.2:8080/chat'
        ws.value = new WebSocket(url);
        ws.value.onopen =  onWsOpen;
        ws.value.onclose = onWsClose;
        ws.value.onerror = onWsError;
        ws.value.onmessage = onWsMessage;
      } catch (e) {
        console.log(`rmb, login exception: ${e}`);
      }
    }
    return {
      onESCreate
    }
  }
})
</script>


<style scoped>

</style>
